import 'package:flutter/material.dart';

class HomeList extends StatelessWidget {
  const HomeList({super.key, required this.notifyList});

  final List notifyList;
  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        // 标题
        Row(
          children: [
            Image.asset(
              'assets/images/notice@2x.png',
              width: 25,
            ),
            const SizedBox(width: 10),
            const Text('社区',
                style: TextStyle(fontSize: 16, fontWeight: FontWeight.w700)),
            const Text(
              '公告',
              style: TextStyle(
                  fontSize: 16,
                  fontWeight: FontWeight.w700,
                  color: Colors.orange),
            ),
          ],
        ),
        //  列表
        ListView(
          // 解决listview 嵌套问题
          shrinkWrap: true,
          // jinyong 滑动
          physics: const NeverScrollableScrollPhysics(),
          children: notifyList
              .map((item) => GestureDetector(
                    // 添加点击事件
                    onTap: () {
                      Navigator.pushNamed(context, '/detail',
                          arguments: item['id']);
                    },
                    child: Container(
                      padding: const EdgeInsets.all(10),
                      margin: const EdgeInsets.only(top: 10),
                      decoration: BoxDecoration(
                        color: Colors.white,
                        borderRadius: BorderRadius.circular(10),
                      ),
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                          Text(
                            item['title'],
                            style: const TextStyle(fontWeight: FontWeight.w700),
                          ),
                          const SizedBox(height: 5),
                          Text(
                            item['content'],
                          ),
                          const SizedBox(height: 5),
                          Text(
                            item['createdAt'],
                            style: const TextStyle(color: Colors.grey),
                          ),
                        ],
                      ),
                    ),
                  ))
              .toList(),
        ),
      ],
    );
  }
}
